
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

abstract class Shape implements Comparable<Shape>{
	public final static double PI=3.14;
	public abstract double getPerimeter();
	public abstract double getArea();
	
	public int compareTo(Shape o) {
		if(this.getPerimeter()-o.getPerimeter()>0)
			return 1;
		else if(this.getPerimeter()-o.getPerimeter()<0)
			return -1;
		else
			return 0;
	}
}
class Rectangle extends Shape{
	private int width;
	private int length;
	public Rectangle(int width, int length){
		this.width = width;
		this.length = length;
	}
	
	public String toString(){
		return String.format("Rectangle [width=%d, length=%d]", width, length);
	}
	
	public double getPerimeter(){
		return (width+length)*2;
	}
	
	public double getArea(){
		return width*length;
	}

}
class Circle extends Shape{
	private int radius;
	public Circle(int radius){
		this.radius = radius;
	}
	
	public String toString(){
		return String.format("Circle [radius=%d]", radius);
	}
	
	public double getPerimeter(){
		return Shape.PI*2*radius;
	}
	
	public double getArea(){
		return Shape.PI*radius*radius;
	}
}
class Perimetercompare implements Comparator<Shape>{
	public int compare(Shape o1, Shape o2){
		if(o1.getPerimeter()-o2.getPerimeter()>0)
			return 1;
		else if(o1.getPerimeter()-o2.getPerimeter()<0)
			return -1;
		else
			return 0;
	}
}

public class boke {
	public static double sumAllArea(Shape[] shape){
		double sum=0;
		for(Shape e:shape){
			sum+=e.getArea();
		}
		return sum;
	}
	public static double sumAllPerimeter(Shape[] shape){
		double sum=0;
		for(Shape e:shape){
			sum+=e.getPerimeter();
		}
		return sum;
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=Integer.parseInt(sc.nextLine());
		Shape[] shapes=new Shape[n];
		for(int i=0;i<n;i++){
			String line =sc.nextLine();
			if(line.equals("rect")){
				String []num=sc.nextLine().split(" ");
				 Rectangle rec=new  Rectangle(Integer.parseInt(num[0]),Integer.parseInt(num[1]));
				 shapes[i]=rec;
			}
			else{	
				Circle cir=new Circle(Integer.parseInt(sc.nextLine()));
				shapes[i]=cir;
			}
		}
		Arrays.sort(shapes);
		for(int i=0;i<shapes.length;i++){
			System.out.println(shapes[i]);
		}
	}
}
